<?php
/*
* Kusht Mud.
* ----
* The MIT License
* Copyright (c) 2010 Andrew Tutt
* ----
*/

/* Item Class
*
*  These are those things we call "Items" i.e. Everything in the whole world.
*/

/* We have some options here because we have done such a good job of abstraction.
*  We could make our items totally straightforward. 
*  Or we could make them really interesting, by screwing with their base
*  stats in all kinds of interesting ways. But that of course requires that we
*  give them some interesting base states. They have to be non-enumerable (we have
*  flags for that). So armor class, damage modifier...and...? 
*  rate of wear, critical hits, variability across items, tweakability (max stats)
*  anything else...? Weapon set (can be determined by script on vnums though)...
*  
*/

class Item extends BaseObject {	
	// If you need ExtraDescription, write a MetaText and link to it using Markup
	// Affects inherited from BaseObject.
	// Weight inherited from BaseObject.
	
	// SET IN ALL_FLAGS
	// item_type: Set in All_Flags
	// wear_location: Set in All_Flags
	
	// When the item expires and is removed from the game...
	public $timer;
	
	function __construct() {
		set_fields_equal($this,new BaseObject()); // Don't override the previous constructor
		$this->name = "A default item " . $this->copy_id;
		$this->description = "A default item description.";
		$this->image = "item.jpg";  
		$this->thumb = "item_thumb.jpg";  
		$this->timer = DEF_NEG; // Infinite expiry
	}
	
	function move_to($object) {
		$this->in_object->rmv_item($this);
		$this->in_object = $object;
		$object->add_item($this);
	}
	
	// -- Database Instanced Storage
	function retain() {
		dbHandler::retain($this);
	}
	
	// (aka load an instance of this item)
	function grab($instanceid) {
		set_fields_equal($this,dbHandler::grab($this,$instanceid));
		rmv_slashes_object($this);
	}
	
	function erase() {
		dbHandler::erase($this);		
	}
}

?>